package 预习的;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayList数组 {
    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList<>();
        getInfo(list);
        //getInfo(list);
        //getInfo(list);

        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println("姓名" + stu.getName() + "  年龄" + stu.getAge() + "  性别" + stu.getSex() + "  分数" + stu.getScore());

        }


        //Student s1 = new Student("高原","男",22,90);
        //Student s2 = new Student("王天浩","男",22,90);
        //Student s3 = new Student("赵子博","男",22,90);

        //ArrayList<Student> list = new ArrayList<>();
        //list.add(s1);
        //list.add(s2);
        //list.add(s3);

        //for (int i = 0; i < list.size(); i++) {
        //    Student s = list.get(i);
        //    System.out.println(s.getAge());
        //
        //}
    }

    public static void getInfo(ArrayList<Student> array) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的名字：");
        String name = sc.next();
        System.out.println("请输入你的年龄：");
        int age = sc.nextInt();
        System.out.println("请输入你的性别：");
        String sex = sc.next();
        System.out.println("请输入你的分数：");
        int score = sc.nextInt();

        Student s = new Student(name,sex,age,score);
        //s.setName(name);
        //s.setAge(age);
        //s.setScore(score);
        //s.setSex(sex);

        array.add(s);

    }
}
